var gulp = require('gulp'),
    ngmin = require('gulp-ngmin'),
    minifycss = require('gulp-minify-css'),
    concat = require('gulp-concat'),
    uglify = require('gulp-uglify'),
    rename = require('gulp-rename'),
    jshint = require('gulp-jshint'),
    less = require('gulp-less');
gulp.task('move', function() {
    gulp.src(['main.js', 'js/*.js']).pipe(gulp.dest('dist/js'));
    gulp.src('css/*.css').pipe(gulp.dest('dist/css'));
    gulp.src('icons/*').pipe(gulp.dest('dist/icons'));
    gulp.src('fonts/*').pipe(gulp.dest('dist/fonts'));
    gulp.src('fonts/RobotoTTF/*').pipe(gulp.dest('dist/fonts/RobotoTTF'));
});
gulp.task('jshint', function() {
    return gulp.src('dist/js/*.js')
        .pipe(jshint())
        .pipe(jshint.reporter('default'));
});
gulp.task('minifyjs', function() {
    return gulp.src(['dist/js/main.js', 'dist/js/services.js', 'dist/js/controllers.js', 'dist/js/directives.js', 'dist/js/animation.js']) //需要操作的文件
        .pipe(concat('app.js'))
        .pipe(ngmin({dynamic: false}))
        .pipe(rename({suffix: '.min'}))
        .pipe(uglify())
        .pipe(gulp.dest('dist/js'));
});
gulp.task('minifycss', function() {
    return gulp.src('dist/css/*.css')
        .pipe(concat('app.css'))
        .pipe(rename({suffix: '.min'}))
        .pipe(minifycss())
        .pipe(gulp.dest('dist/css'));
});
gulp.task('default', ['testLess', 'move', 'jshint', 'minifyjs', 'minifycss']);
gulp.task('ngmin', function() {
    return gulp.src('js/*')
        .pipe(ngmin({dynamic: false}))
        .pipe(gulp.dest('js'));
});
gulp.task('testLess', function() {
    gulp.src('css/*.less')
        .pipe(less())
        .pipe(gulp.dest('css'));
});
gulp.task('testWatch', function() {
    gulp.watch('css/*.less', ['testLess']);
});
gulp.task('less', ['testLess', 'testWatch']);